<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/rp/common/taglib.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <base href="<%=basePath%>">
    
    <title>操作日志管理</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	
	<script src="rp/scripts/boot.js" type="text/javascript"></script>
	
	<style type="text/css">
	   	
    </style>
	
  </head>
  
  <body class="body-fit">
  	
  	<div style="width:100%;">
        <div class="mini-toolbar" style="padding:0px;border-top:0;border-left:0;border-right:0;">
            <table style="width:100%;">
                <tr>
                    <td style="width:100%;">
                    	<sec:authorize ifAllGranted="AUTH_SUPERADMIN">
                    		<a class="mini-button mini-button-danger" onclick="removeAll()"><i class="fa fa-trash-o fa-lg"></i> 清空所有记录</a>  
                    	</sec:authorize>
                    </td>
                    <td style="white-space:nowrap;">
                    	
                    </td>
                </tr>
            </table>           
        </div>
    </div>
    <div class="mini-fit">
	  	<div id="sysLogGrid" class="mini-datagrid" style="width: 100%; height:100%;" borderStyle="border:0;"
	    	url="rp/system/sysLogMng/getSysLogByPage" idField="id"
	    	pageSize="20" allowResize="false"
	    	allowCellEdit="true" allowCellSelect="true" 
	    	multiSelect="true" showFilterRow="true">
		    <div property="columns">
		        <div type="indexcolumn" headerAlign="center">序号</div>
		        <div type="checkcolumn"></div>
		        <div field="description" width="" headerAlign="center">
		        	操作描述
		        	<input id="descriptionFilter" property="filter" class="mini-textbox" style="width:100%;" emptyText="输入操作描述搜索"
		            	onenter="onFilterEnter"/>
		        </div>    
		        <div field="operResult" width="40" headerAlign="center" align="center" allowSort="true" renderer="onOperResultRenderer">
		        	执行结果
		        	<input id="operResultFilter" property="filter" 
		        		class="mini-combobox" style="width:100%;" emptyText=""
		                onvaluechanged="onFilterEnter" 
		                showNullItem="true"
		                data="[{id:'成功', text:'成功'}, {id:'失败', text:'失败'}]"/>
		        </div> 
		        <div field="exceptionMsg" width="150" headerAlign="center">
		        	异常信息
		        	<input property="editor" class="mini-textarea" style="width:200px;" minWidth="200" minHeight="50"/>
		        </div> 
		        <div field="className" width="120" headerAlign="center">
		        	全路径类名
		        	<input property="editor" class="mini-textarea" style="width:200px;" minWidth="200" minHeight="50"/>
		        </div>
		        <div field="methodName" width="80" headerAlign="center">
		        	方法名
		        	<input id="methodNameFilter" property="filter" class="mini-textbox" style="width:100%;" emptyText="输入方法名搜索"
		            	onenter="onFilterEnter"/>
		        </div>
		        <div field="params" width="150" headerAlign="center">
		        	传入参数
		        	<input property="editor" class="mini-textarea" style="width:200px;" minWidth="200" minHeight="50"/>
		        </div>
		        <div field="executorName" width="80" headerAlign="center">
		        	执行者
		        </div>
		        <div field="createDate" width="90" headerAlign="center" allowSort="true" renderer="onDateRenderer">
		        	执行时间
		        	<input id="createDateFilter" property="filter" 
		        		class="mini-datepicker" style="width:100%;" emptyText=""
		                onvaluechanged="onFilterEnter" allowInput="false"/>
		        </div>                
		    </div>
		</div>
		
	</div>
  	
	<script type="text/javascript">
		var grid;
		$(function(){
			mini.parse();
			
			grid = mini.get("sysLogGrid");
			grid.load();
			
		});
		
		function onOperResultRenderer(e){
			var value = e.value;
			if(value){
				if(value == "成功") {
					return "<i class='fa fa-check fa-2x'></i>"
				}
				return "<i class='fa fa-times fa-2x'></i>";
			}
			return "";
		}
		
		function removeAll(){
			mini.confirm("确定删除记录吗？", "友情提示",
	            function (action) {
	                if (action == "ok") {
	                	rp_ajax("rp/system/sysLogMng/removeAll",{},function(result){
	                		if(result == "success"){
		    					mini.alert("已清空所有日志记录");
		    					grid.reload();
		    				}
	        			});
	                }
	            }
	        );
			
		}
		
		function onFilterEnter(e) {
			var description = mini.get("descriptionFilter").getValue();
			var operResult = mini.get("operResultFilter").getValue();
			var methodName = mini.get("methodNameFilter").getValue();
			var createDate = mini.get("createDateFilter").getFormValue();
            grid.load({ description:description, operResult: operResult, methodName: methodName, createDate: createDate });
        }
		
	</script>
  </body>
</html>
